﻿<?php require_once('../Connections/conexao.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO categorias (categoria) VALUES (%s)",
                       GetSQLValueString($_POST['categoria'], "text"));

  mysql_select_db($database_conexao, $conexao);
  $Result1 = mysql_query($insertSQL, $conexao) or die(mysql_error());

  $insertGoTo = "categoria.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
<!doctype html>

<!--[if lt IE 7]> <html class="ie6 oldie"> <![endif]-->
<!--[if IE 7]>    <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <html class="ie8 oldie"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>categoria</title>
<link href="CSS ADMIN/boilerplate.css" rel="stylesheet" type="text/css">
<link href="CSS ADMIN/TEMPLAITE.css" rel="stylesheet" type="text/css">
<!-- 
Para saber mais sobre os comentários condicionais sobre as tags html na parte superior do arquivo:
paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/

Se você estiver usando a compilação personalizada do modernizr (http://www.modernizr.com/), faça o seguinte:
* insira o link para o seu js aqui
* remova o link abaixo para o html5shiv
* adicione a classe "no-js" às tags html na parte superior
* você também pode remover o link para respond.min.js se tiver incluído o MQ Polyfill na sua compilação do modernizr 
-->
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/respond.min.js"></script>
</head>
<body>
<div class="gridContainer clearfix">
  <div id="LayoutDiv1">
  <table width="960" align="center">
  <tr>
    <td colspan="2">
	<?php 
	include ("../temadmin/cabecalho.php");
	?>
    </td>
  </tr>
  <tr>
    <td colspan="2">
	<?php 
	include "../temadmin/menu_vertical.php";
	?>
    </td>
  </tr>
  <tr>
    <td width="250">
	  <p>
	    <?php 
	include "../temadmin/menu.php";
	?>
    </td>
   
    
    <td width="698">
     <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <div align="center"><strong>Inserir Categoria</strong></div>
    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
  <table border="1" align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Categoria:</td>
      <td><input type="text" name="categoria" value="" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td colspan="2" align="right" nowrap="nowrap"><input type="submit" value="Inserir registro" /></td>
      </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1" />
</form>

    </td>
  </tr>
  <tr>
    <td colspan="2">
	<?php 
	include ("../temadmin/rodape.php");
	?>
    </td>
  </tr>
</table>
  </div>
</div>

</body>
</html>
